
#include "download_task_thread.h"

DownloadTaskThread &DownloadTaskThread::instance()
{
    static DownloadTaskThread instance;
    return instance;
}

DownloadTaskThread::~DownloadTaskThread()
{

}

DownloadTaskThread::DownloadTaskThread(QObject *parent)
        : QThread(parent)
{

}

void DownloadTaskThread::run()
{
    while(!is_stop_)
    {
        while(down_finish_)
        {
            if(!task_list_.isEmpty())
            {
                // 执行下载任务
                QString name = task_list_.takeFirst();
                down_finish_ = false;
                emit sig_download(name);
            }
        }
    }
}

void DownloadTaskThread::stop()
{
    is_stop_ = true;
    down_finish_ = false;
}

void DownloadTaskThread::setTask(const QStringList &task)
{
    task_list_ = task;
}
void DownloadTaskThread::downFinished()
{
    down_finish_ = true;
}
